import express from 'express';
import { authenticateToken } from '../middleware/auth.js';
import storyService from '../services/storyService.js';

const router = express.Router();

router.post('/generate', authenticateToken, async (req, res) => {
  try {
    const { toyName } = req.body;
    
    if (!toyName) {
      return res.status(400).json({
        success: false,
        message: '玩具名称不能为空'
      });
    }

    const result = await storyService.generateStory(toyName);
    res.json(result);
  } catch (error) {
    console.error('Story generation error:', error);
    res.status(500).json({
      success: false,
      message: '故事生成服务暂时不可用'
    });
  }
});

export default router; 